<template>
  <div class="group-card w-100">
    <div class="group-card-title d-flex">
      <h2 class="font-black fs-lg card-title" :class="isHasSearch ? 'large-size':''">{{title}}</h2>
      <router-link tag="a" class="font-black fs-sm" v-if="isHasMore" :to="link? link :''">>>更多</router-link>
      <div class="input-group-search" v-if="isHasSearch">
        <input type="text" placeholder="小组搜索" class="input-search" v-model="searchInput">
        <span class="icon-container"><button @click="submitForm"><i class="iconfont icon-search"></i></button></span>
      </div>
    </div>
    <div class="group-card-body">
      <div class="body-group-list d-flex">
        <slot></slot>
      </div>
    </div>
  </div>
</template>

<script>
import { ref } from 'vue'
export default {
  props: ['title', 'isHasMore', 'link', 'isHasSearch'],
  emits: ['mysearch'],
  setup (props, context) {
    // 子向父传值
    const searchInput = ref('')
    function submitForm () {
      context.emit('mysearch', searchInput.value)
    }
    return { submitForm, searchInput }
  }
}
</script>

<style lang="scss" scoped>
.group-card {
  background-color: #fff !important;
  margin-bottom: 20px;
  .group-card-title {
    padding: 18px 15px;
    justify-content: space-between;
    border-bottom: 1px solid #f0f0f0;
    .card-title {
      margin: 0 !important;
      &.large-size {
        font-size: 22px;
      }
    }
    .input-group-search {
      display: flex;
      input {
        width: 85%;
        padding: 6px 12px;
        height: 34px;
        outline: none;
        font-size: 14px;
        border: 1px solid #f0f0f0 !important;
        &:focus {
          border: 1px solid #15c288 !important;
        }
      }
      .icon-container {
        display: block;
        width: 15%;
        height: 34px;
        border: 1px solid #15c288;
        button {
          width: 100%;
          height: 100%;
          outline: none;
          border: none;
          background-color: #fff;
          display: block;
          text-align: center;
          line-height: 34px;
        }
        .iconfont {
          color: #15c288;
        }
      }
    }
  }
  .group-card-body {
    padding: 15px;
    .body-group-list {
      flex-wrap: wrap;
    }
  }
}
</style>
